package com.pony.iphone.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 跨域配置类
 * @auther pony
 * @create 2025-10-30 15:11
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    //设置跨域的路径
    @Override
    public void addCorsMappings(CorsRegistry registry){
        //设置允许跨域的路径
        registry.addMapping("/**")
                .allowedOrigins(
                        "http://qtaf8211650.vicp.fun:52673",
                        "http://localhost:52673"
                )
                //设置允许跨域请求的地址
                .allowedOriginPatterns("*")
                //是否允许 cookie
                .allowCredentials(true)
                //设置允许跨域请求的方式
                .allowedMethods("GET","POST","DELETE","PUT")
                //设置允许header属性
                .allowedHeaders("*")
                //跨域允许时间
                .maxAge(3600);
    }
}
